import request from "../utils/request"
import { Message } from "element-ui"
export function fetchList(params) {
  return request({
    url:'/market/getList',
    method:'post',
    data:params
  })
}

export function fetchSimpleList(params) {
  return request({
    url:'/product/simpleList',
    method:'get',
    params:params
  })
}



export function updateDeleteStatus(params) {
  return request({
    url:'/product/update/deleteStatus',
    method:'post',
    params:params
  })
}

export function updateMarket(params) {
  return request({
    url:'/market/update',
    method:'post',
    data:params
  })
}

export function updateNewStatus(params) {
  return request({
    url:'/product/update/newStatus',
    method:'post',
    params:params
  })
}

export function updateRecommendStatus(params) {
  return request({
    url:'/product/update/recommendStatus',
    method:'post',
    params:params
  })
}

export function updatePublishStatus(params) {
  return request({
    url:'/market/publishStatus',
    method:'post',
    data:params
  })
}

export function updateHot(status, ids) {

  let requestStr = "";
  requestStr = requestStr.concat("hot=", status, "&", "ids=", ids)

  console.log("requestStr", requestStr)

  return request({
    url:'/market/updateHot',
    method:'post',
    data:requestStr
  }).then(res => {
    Message({
      message: res.message,
      type: 'success',
      duration: 3 * 1000
    })
  })
}


export function getListBySearchRequest(params) {
  return request({
    url:'/market/getListBySearch',
    method:'post',
    data:params
  })
}

export function createProduct(data) {
  return request({
    url:'/market/create',
    method:'post',
    data:data
  })
}

export function updateProduct(id,data) {
  return request({
    url:'/product/update/'+id,
    method:'post',
    data:data
  })
}

export function getProduct(id) {
  return request({
    url:'/product/updateInfo/'+id,
    method:'get',
  })
}

